# 将三维坐标转换为体素坐标


import torch
from torch_geometric.nn.pool import voxel_grid

pos = torch.tensor([[0.1, 0.2, 0.3], [1.2, 0.8, 2.7], [0.9, 0.2, 2.6]])
# pos = torch.tensor([[1, 2, 3], [1, 2, 3], [2, 3, 4], [1, 2, 4]])
pos = torch.tensor([[0, 0, 1], [1, 1, 1], [1, 0, 0]])


batch = torch.tensor([0, 0, 0])

# voxel_id = voxel_grid(pos, size=1, batch=batch)
voxel_id = voxel_grid(pos, size=[1], batch=batch)

print(voxel_id)


# import torch
# from torch_cluster import knn_graph  # 尝试导入关键函数

# # 生成示例数据
# x = torch.tensor([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])
# # 使用KNN算法生成图连接（k=2）
# edge_index = knn_graph(x, k=2)

# print("torch_cluster 安装成功！")
# print("生成的边索引：\n", edge_index)




